<?php defined('IN_KG') or exit('Access Invalid!');?>
<style type="text/css">
.sticky .tabmenu { padding: 0;  position: relative; }
.select-goods-box {
    padding: 10px 20px;
    border: 1px solid #999;
    margin: 0 20px;
}
.select-goods-box .goods-box{
    max-height: 350px;
    overflow-y: scroll;
}
.select-goods-box label {
    display: block;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.select-goods-box span.input-box , .select-goods-box img.thumb {
    display: block;
    float: left;
    width: 40px;
    height: 40px;
}
.select-goods-box .order-goods {
    padding-left: 100px;
    text-align: left;
}
#select-goods-dialog{
    display: none;
    position: fixed;
    width: 500px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background: #fff;
    z-index: 999;
}
.pl60{
    padding-left: 60px !important;
}
</style>
<span class="fr mr5"> 
    <a href="<?php echo urlShop('store_deliver', 'waybill_print', array('order_id' => $output['order_info']['order_id']));?>" class="ncbtn-mini" target="_blank" title="打印运单"/><i class="icon-print"></i>打印运单</a>
</span>
<div class="wrap">
  <div class="step-title"><em><?php echo $lang['store_deliver_first_step'];?></em><?php echo $lang['store_deliver_confirm_trade'];?></div>
  <form name="deliver_form" method="POST" id="deliver_form" action="index.php?control=store_deliver&op=sendPackage&order_id=<?php echo $_GET['order_id'];?>" onsubmit="ajaxpost('deliver_form', '', '', 'onerror');return false;">
    <input type="hidden" value="<?php echo getReferer();?>" name="ref_url">
    <input type="hidden" value="ok" name="form_submit">
    <!-- <input type="hidden" id="shipping_express_id" value="<?php echo $output['order_info']['shipping_express_id'];?>" name="shipping_express_id"> -->
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_name'];?>" name="reciver_name" id="reciver_name">
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_info']['area'];?>" name="reciver_area" id="reciver_area">
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_info']['street'];?>" name="reciver_street" id="reciver_street">
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_info']['mob_phone'];?>" name="reciver_mob_phone" id="reciver_mob_phone">
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_info']['tel_phone'];?>" name="reciver_tel_phone" id="reciver_tel_phone">
    <input type="hidden" value="<?php echo $output['order_info']['extend_order_common']['reciver_info']['dlyp'];?>" name="reciver_dlyp" id="reciver_dlyp">
    <table class="ncsc-default-table order deliver">
    <tbody>
        <?php if (is_array($output['order_info']) and !empty($output['order_info'])) { ?>
        <tr>
            <td colspan="20" class="sep-row"></td>
        </tr>
        <tr>
            <th colspan="20">
            <a href="index.php?control=store_order&op=order_print&order_id=<?php echo $output['order_info']['order_id'];?>" target="_blank" class="fr" title="<?php echo $lang['store_show_order_printorder'];?>"/><i class="print-order"></i></a>
            <span class="fr mr30"></span>
            <span class="ml10"><?php echo $lang['store_order_order_sn'].$lang['nc_colon'];?><?php echo $output['order_info']['order_sn']; ?></span>
            <span class="ml20"><?php echo $lang['store_order_add_time'].$lang['nc_colon'];?><em class="goods-time"><?php echo date("Y-m-d H:i:s",$output['order_info']['add_time']); ?></em></span>
        </tr>
        <?php $other_info = false; ?>
        <?php foreach($output['order_info']['extend_order_goods'] as $k => $goods_info) { ?>
        <?php if(in_array($goods_info['rec_id'], $output['order_info']['package_goods'])) continue; ?>
        <tr>
            <td class="bdl w10"><input class="ml10 mr10 mt10" checked="true" type="checkbox" name="order_goods[<?php echo $goods_info['rec_id']; ?>]" id="order_goods_<?php echo $goods_info['rec_id']; ?>" value="1"></td>
            <td class="w50"><div class="pic-thumb"><a href="<?php echo urlShop('goods','index',array('goods_id'=>$goods_info['goods_id']));?>" target="_blank"><img src="<?php echo cthumb($goods_info['goods_image'],'60',$$output['order_info']['store_id']); ?>" /></a></div></td>
            <td class="tl">
                <label class="goods-name" for="order_goods_<?php echo $goods_info['rec_id']; ?>">
                    <dl>
                    <dt><a target="_blank" href="<?php echo urlShop('goods','index',array('goods_id'=>$goods_info['goods_id']));?>"><?php echo $goods_info['goods_name']; ?></a>
                    </dt>
                    <dd><strong><?php echo $goods_info['goods_spec']; ?></strong>&nbsp;x&nbsp;<em><?php echo $goods_info['goods_num'];?></em>件</dd></dl>
                </label>
            </td>
            <?php if (((count($output['order_info']['extend_order_goods']) - count($output['order_info']['package_goods'])) > 1 || 
                        (count($output['order_info']['extend_order_goods']) == 1)) && !$other_info){?>
            <td class="bdl bdr order-info w500" rowspan="<?php echo count($output['order_info']['extend_order_goods'])+1;?>">
                <dl>
                    <dt><?php echo $lang['store_deliver_shipping_amount'].$lang['nc_colon'];?></dt>
                    <dd>
                        <?php if (!empty($output['order_info']['shipping_fee']) && $output['order_info']['shipping_fee'] != '0.00'){?>
                        <?php echo $output['order_info']['shipping_fee'];?>
                        <?php }else{?>
                        <?php echo $lang['nc_common_shipping_free'];?>
                        <?php }?>
                    </dd>
                </dl>
                <dl>
                    <dt><?php echo $lang['store_deliver_forget'].$lang['nc_colon'];?></dt>
                     <dd>
                        <textarea name="deliver_explain" cols="100" rows="2" class="w400 tip-t" title="<?php echo $lang['store_deliver_forget_tips'];?>"><?php echo $output['order_info']['extend_order_common']['deliver_explain'];?></textarea>
                    </dd>
                </dl>
            </td>
            <?php $other_info = true; ?>
            <?php }?>
        </tr>
        <?php }?>
        <tr>
            <td class="bdl w10"><input type="checkbox" onclick="selectAllGoods(this)" id="selectAllGoodsBtn" checked="true"></td>
            <td class="w50"></td>
            <td><label for="selectAllGoodsBtn" style="display: block;">全选/反选</label></td>
        </tr>
        <tr>
          <td colspan="20" class="tl bdl bdr" style="padding:8px" id="address"><strong class="fl"><?php echo $lang['store_deliver_buyer_adress'].$lang['nc_colon'];?></strong><span id="buyer_address_span"><?php echo $output['order_info']['extend_order_common']['reciver_name'];?>&nbsp;<?php echo $output['order_info']['extend_order_common']['reciver_info']['phone'];?>&nbsp;<?php echo $output['order_info']['extend_order_common']['reciver_info']['address'];?></span><?php echo $output['order_info']['extend_order_common']['reciver_info']['dlyp'] ? '[自提服务站]' : '';?>
          <a href="javascript:void(0)" nc_type="dialog" dialog_title="<?php echo $lang['store_deliver_buyer_adress'];?>" dialog_id="edit_buyer_address" uri="index.php?control=store_deliver&op=buyer_address_edit&order_id=<?php echo $output['order_info']['order_id'];?>" dialog_width="550" class="ncbtn-mini fr"><i class="icon-edit"></i><?php echo $lang['nc_edit'];?></a></td>
        </tr>
        <?php } else { ?>
        <tr>
          <td colspan="20" class="norecord"><i>&nbsp;</i><span><?php echo $lang['no_record'];?></span></td>
        </tr>
        <?php } ?>
    </tbody>
    </table>
    <div class="step-title mt30"><em><?php echo $lang['store_deliver_second_step'];?></em><?php echo $lang['store_deliver_confirm_daddress'];?></div>
    <div class="deliver-sell-info"><strong class="fl"><?php echo $lang['store_deliver_my_daddress'].$lang['nc_colon'];?></strong>
      <a href="javascript:void(0);" onclick="ajax_form('modfiy_daddress', '<?php echo $lang['store_deliver_select_daddress'];?>', 'index.php?control=store_deliver&op=send_address_select&order_id=<?php echo $output['order_info']['order_id'];?>', 640,0);" class="ncbtn-mini fr"><i class="icon-edit"></i><?php echo $lang['nc_edit'];?></a> <span id="seller_address_span">
      <?php if (empty($output['daddress_info'])) {?>
      <?php echo $lang['store_deliver_none_set'];?>
      <?php } else { ?>
      <?php echo $output['daddress_info']['seller_name'];?>&nbsp;<?php echo $output['daddress_info']['telphone'];?>&nbsp;<?php echo $output['daddress_info']['area_info'];?>&nbsp;<?php echo $output['daddress_info']['address'];?>
      <?php } ?>
      </span>
    </div>
    <input type="hidden" name="daddress_id" id="daddress_id" value="<?php echo $output['daddress_info']['address_id'];?>">
    <div class="step-title mt30"><em><?php echo $lang['store_deliver_third_step'];?></em><?php echo $lang['store_deliver_express_select'];?></div>
    <div class="alert alert-success"><?php echo $lang['store_deliver_express_note'];?></div>
    <div class="tabmenu">
      <ul class="tab pngFix">
        <li id="eli1" class="active"><a href="javascript:void(0);" onclick="etab(1)"><?php echo $lang['store_deliver_express_zx'];?></a></li>
        <?php if ($output['order_info']['extend_order_common']['reciver_info']['dlyp'] == '') {?>
        <li id="eli2" class="normal"><a href="javascript:void(0);" onclick="etab(2)"><?php echo $lang['store_deliver_express_wx'];?></a></li>
        <?php } ?>
      </ul>
    </div>
    <table class="ncsc-default-table order" id="texpress1">
    <tbody>
        <tr>
            <td class="bdl w150"><?php echo $lang['store_deliver_company_name'];?></td>
            <td class="w250"><?php echo $lang['store_deliver_shipping_code'];?></td>
            <td class="tc"><?php echo $lang['store_deliver_bforget'];?></td>
            <td class="bdr w90 tc"><?php echo $lang['nc_common_button_operate'];?></td>
        </tr>
        <tr>
            <td class="bdl">
                <select name="shipping_express_id" id="">
                <?php if (is_array($output['my_express_list']) && !empty($output['my_express_list'])){?>
                    <?php foreach ($output['my_express_list'] as $k=>$v){?>
                        <?php if (!isset($output['express_list'][$v])) continue;?>
                            <option value="<?php echo $v;?>" <?php if($v == 44) echo "selected='true'"; ?>><?php echo $output['express_list'][$v]['e_name'];?></option>
                        <?php }?>
                    <?php }?>
                </select>
            </td>
            <td class="bdl">
                <input name="shipping_code" id="shipping_code" type="text" class="text w200 tip-r" title="<?php echo $lang['store_deliver_shipping_code_tips'];?>" maxlength="20" nc_type='eb' nc_value="<?php echo $v;?>" />
            </td>
            <td class="bdl gray" nc_value="<?php echo $v;?>">
            </td>
            <td class="bdl bdr tc">
                <a nc_type='eb' nc_value="" href="javascript:void(0);" class="ncbtn"><?php echo $lang['nc_common_button_confirm'];?></a>
            </td>
        </tr>
    </tbody>
    </table>
    <table class="ncsc-default-table order" id="texpress2" style="display:none">
      <tbody>
        <tr>
          <td colspan="2"></td>
        </tr>
        <tr>
          <td class="bdl tr"><?php echo $lang['store_deliver_no_deliver_tips'];?></td>
          <td class="bdr tl w400">&emsp;<a nc_type='eb' nc_value="e1000" href="javascript:void(0);" class="ncbtn"><?php echo $lang['nc_common_button_confirm'];?></a></td>
        </tr>
        <tr>
          <td colspan="2"></td>
        </tr>
      </tbody>
    </table>
    <pre hidden><?php print_r($output['order_info']); ?></pre>
  </form>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.poshytip.min.js"></script>
<script charset="utf-8" type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js" ></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />

<script type="text/javascript" data-time="2017年5月3日11:30:18">
    var goods_id = <?php echo json_encode($goods_ids); ?>;
    var goods_selected = [];
    var goods_dialog = $('#select-goods-dialog'),
        goods_selects = goods_dialog.find('.one');

    $('#texpress3').on('click', 'a[hdy-dialog="goods"]', function(event) {
        event.preventDefault();
        var _that = $(this);
        var index = _that.parent().data('index');
        console.log(index);
        for (var i = goods_selected.length - 1; i >= 0; i--) {
            $('#order_goods_'+goods_selected[i]).prop('checked', true)
                                                .parent().parent().hide();
        }
        goods_dialog.data('package', index).show();
    });

    var deliver_table = $('table.deliver'),
        deliver_cb = deliver_table.find('input[type=checkbox]');

    function selectAllGoods(obj){
        deliver_cb.prop('checked', obj.checked);
    }
</script>
<script type="text/javascript">
    function etab(t){
    	if (t==1){
    		$('#eli1').removeClass('normal').addClass('active');
    		$('#eli2').removeClass('active').addClass('normal');
    		$('#texpress1').css('display','');
    		$('#texpress2').css('display','none');
    	}else{
    		$('#eli1').removeClass('active').addClass('normal');
    		$('#eli2').removeClass('normal').addClass('active');
    		$('#texpress1').css('display','none');
    		$('#texpress2').css('display','');
    	}
    }
    $(function(){
    	//表单提示
    	$('.tip-t').poshytip({
    		className: 'tip-yellowsimple',
    		showOn: 'focus',
    		alignTo: 'target',
    		alignX: 'center',
    		alignY: 'top',
    		offsetX: 0,
    		offsetY: 2,
    		allowTipHover: false
    	});
    	$('.tip-r').poshytip({
    		className: 'tip-yellowsimple',
    		showOn: 'focus',
    		alignTo: 'target',
    		alignX: 'right',
    		alignY: 'center',
    		offsetX: -50,
    		offsetY: 0,
    		allowTipHover: false
    	});
    	$('a[nc_type="eb"]').on('click',function(){
    		if ($('#shipping_code').val() == ''){
    			showDialog('<?php echo $lang['store_deliver_shipping_code_pl'];?>', 'error','','','','','','','','',2);return false;
    		}
    		/*$('input[nc_type="eb"]').attr('disabled',true);
    		$('input[nc_value="'+$(this).attr('nc_value')+'"]').attr('disabled',false);
    		$('#shipping_express_id').val($(this).attr('nc_value'));*/
    		$('#deliver_form').submit();
    	});

        $('#add_time_from').datepicker({dateFormat: 'yy-mm-dd'});
        $('#add_time_to').datepicker({dateFormat: 'yy-mm-dd'});
        $('.checkall_s').click(function(){
            var if_check = $(this).attr('checked');
            $('.checkitem').each(function(){
                if(!this.disabled)
                {
                    $(this).attr('checked', if_check);
                }
            });
            $('.checkall_s').attr('checked', if_check);
        });
        <?php if ($output['order_info']['shipping_code'] != ''){?>
        	$('input[nc_value="<?php echo $output['order_info']['extend_order_common']['shipping_express_id'];?>"]').val('<?php echo $output['order_info']['shipping_code'];?>');
        	$('td[nc_value="<?php echo $output['order_info']['extend_order_common']['shipping_express_id'];?>"]').html('<?php echo $output['order_info']['extend_order_common']['deliver_explain'];?>');
        <?php } ?>

        $('#my_address_add').click(function(){
    		ajax_form('my_address_add', '<?php echo $lang['store_deliver_add_daddress'];?>' , 'index.php?control=store_deliver&op=send_address_edit', 550,0);
        });
    });
</script>
